/**
 * Created by kevin on 2016/9/27.
 * 首页
 */
var eosi = window.eosi || {};
this.eosi.website = this.eosi.website || {};


(function (window) {
    function Assembly(father) {
        this.Container_constructor();
        this.father = father;

        this.init();
    }

    var p = createjs.extend(Assembly, createjs.Container);
    p.father;
    p.loadingAssemblyResLoader;
    //配置
    p.config=[];
    //资源是否加载完毕
    p.resIsLoaded = false;
    p.resItems=[];
    p.addedPage={};
    p.init = function () {
        this.loadAssemblyRes();
    }
    p.loadAssemblyRes = function () {
        // alert(1);
        this.loadingAssemblyResLoader = new createjs.LoadQueue(true);
        this.loadingAssemblyResLoader.on("fileload", this.onLoaded, this);
        this.loadingAssemblyResLoader.on("complete", this.loadingresLoadComplete, this);
        this.loadingAssemblyResLoader.on("progress", this.loadingresOnProgress, this);
        this.loadingAssemblyResLoader.loadManifest({src: "./static/Assembly/AssemblyManifest.json?v="+version, callback: "loadAssemblyMediaGrid", type: "manifest"}, true, "./");
    }
    p.loadingresLoadComplete = function (event) {
        this.resIsLoaded=true;
        // console.log(event);
    }
    p.onLoaded = function (evt){
        var item = evt.item;
        this.resItems.push(item);
    }
    p.loadingresOnProgress = function (event) {
        // var loading_loaded = this.loadingAssemblyResLoader.progress * 100 | 0;
        // this.drawLoadingNum(Math.floor(loading_loaded*0.1));
    }
    p.open=function(name){
        // console.log(name);
        if(this.addedPage[name]){
            document.getElementById(name+"_page").style.display="block";            
        }else{
            this.append(name)
        }
        // document.getElementById("assembly").style.display="block";
    }
    p.append=function(name){
        // document.body.write(dm)
        var div = document.createElement("div");
　　　　div.setAttribute("class", "assembly_div");
        div.setAttribute("id", name+"_page");
　　　　div.innerHTML = this.loadingAssemblyResLoader.getResult(name);
        $("#assembly").html(div);
        this.addedPage[name]=true;
    }
    p.tick = function (evt) {
        
    }


    // add MyApp to myNameSpace
    window.eosi.website.Assembly = createjs.promote(Assembly, "Container");
//}());
}(window));



